#ifndef __MQTT_MAIN_H_
#define __MQTT_MAIN_H_
#include <unistd.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <mosquitto.h>
#include "signal.h"
#include <time.h>
#include <errno.h>
#include <sys/prctl.h>
#include <pthread.h>
#include <fcntl.h>
#include <unistd.h>
#include <semaphore.h>

#define MQTT_HOSTIP "10.10.0.6"
#define MQTT_PORT 1883

#define MQTT_USERNAME "admin"
#define MQTT_PASSWORD "hisome123"


#define SUB_QOS	1
#define	PUB_QOS	1

#define true	1
#define	false	0

#define START_DETECT_CPU 2
#define CPU_NUM 7	//six child cpu

#define ON 1
#define OFF 0


#define CHILD_CPU_REBOOT_TIME (120)  //seconds 复位后，等待多长时间发心跳包
#define SLEEP_BEFORE_LOOP (80)	//其中一个起来后多长时间后，开始循环检查
#define HEARTBEAT_ACK_TIMEOUT_SEC (3)	//心跳包回应等待时间
#define HEARTBEAT_TIMEOUT          (20) //多长时间没接收到心跳包后进行复位
#define TOPIC_ALARM_HEARTBEAT           "DEV/ALARM/HEARTBEAT"
#define TOPIC_ALARM_HEARTBEAT_ACK       "DEV/ALARM/HEARTBEAT/ACK"

#define TOPIC_AV_HEARTBEAT           "DEV/AV/HEARTBEAT"
#define TOPIC_AV_HEARTBEAT_ACK       "DEV/AV/HEARTBEAT/ACK"

#define TOPIC_POWERMGT           "DEV/ALARM/POWERMGT"
#define TOPIC_POWERMGT_ACK       "DEV/ALARM/POWERMGT/ACK"

#define STREAMING_STATUS		"DEV/CORE/STATUS"
#define STREAMING_STATUS_ACK		"DEV/CORE/STATUS/ACK"
#define DEV_ALL		"DEV/#"

#define POWERMGT_AUTO  0
#define POWERMGT_MANUAL 1


int hs_mqtt_init(void);
int hi3518E_heartbeat_control_on();
int hi3518E_heartbeat_control_off();
void g_general_mqtt_publish(char *topic,const char *message);
#endif//__MQTT_MAIN_H_